// ignore: file_names
class UserModel {
  final String? id;
  final String? name;
  final String? password;
  final String? avatar_image;
  List<String>? plant_list;
  final List<String>? water_lists;
  final bool? is_vip;
  final List<String>? like_lists;
  final String? signature;
  final List<String>? post_lists;
  final List<String>? comment_lists;

  UserModel({
    this.id,
    this.name,
    this.password,
    this.avatar_image,
    this.is_vip,
    this.plant_list,
    this.water_lists,
    this.like_lists,
    this.signature,
    this.post_lists,
    this.comment_lists,
  });

  factory UserModel.fromJson(Map<String, dynamic> json) {
    return UserModel(
      id: json['id'],
      name: json['name'],
      password: json['password'],
      avatar_image: json['avatarImage'],
      is_vip: json['isVip'],
      plant_list: List<String>.from(json['plantList'] ?? []),
      water_lists: json['waterLists'] is List
          ? List<String>.from(json['waterLists'])
          : [],
      like_lists: List<String>.from(json['likeLists'] ?? []),
      signature: json['signature'],
      post_lists: List<String>.from(json['postLists'] ?? []),
      comment_lists: List<String>.from(json['commentLists'] ?? []),
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'id': id,
      'name': name,
      'password': password,
      'avatarImage': avatar_image,
      'isVip': is_vip,
      'plantList': plant_list,
      'waterLists': water_lists,
      'likeLists': like_lists,
      'signature': signature,
      'postLists': post_lists,
      'commentLists': comment_lists,
    };
  }

  UserModel copyWith({
    String? id,
    String? name,
    String? password,
    String? avatar_image,
    List<String>? plant_list,
    List<String>? water_lists,
    bool? is_vip,
    List<String>? like_lists,
    String? signature,
    List<String>? post_lists,
    List<String>? comment_lists,
  }) {
    return UserModel(
      id: id ?? this.id,
      name: name ?? this.name,
      password: password ?? this.password,
      avatar_image: avatar_image ?? this.avatar_image,
      plant_list: plant_list ?? this.plant_list,
      water_lists: water_lists ?? this.water_lists,
      is_vip: is_vip ?? this.is_vip,
      like_lists: like_lists ?? this.like_lists,
      signature: signature ?? this.signature,
      post_lists: post_lists ?? this.post_lists,
      comment_lists: comment_lists ?? this.comment_lists,
    );
  }

  @override
  String toString() {
    return 'UserModel(id: $id, name: $name, password: $password, "avatar_image: $avatar_image, is_vip: $is_vip, plant_list: $plant_list, water_lists: $water_lists, like_lists: $like_lists, signature: $signature, post_lists: $post_lists, comment_lists: $comment_lists)';
  }
}
